<header />


<body class="boxed">

<div class="body">

    <!--header start-->
    <!--导航部分-->
    <include file="Common/header_nav" />
    <!--/导航部分-->
    <!-- /end header -->

    <div class="container">

        <div class="row-fluid">

            <div class="col-md-12">

                <div class="panel">
                    <div class="panel-heading">
                        问卷属性设置
                    </div>

                    <div class="panel-body">
                        <div class="row">
                            <div class="col-md-10">

                                <div class="panel">
                                    <div class="panel-body">

                                        <label>点击选择问卷</label>

                                        <select class="form-control" id="quiz_list_select">
                                            <foreach name="quiz_list" item="quiz">
                                            <option>{$quiz.quiz_name}</option></foreach>
                                        </select>

                                        <label class="">问卷结果是否对被测者可见</label>
                                        <label class="checkbox checkbox-custom">
                                            <input type="checkbox" id="isvisible">
                                            <i class="checkbox"></i>打勾对被测者可见</label>
                                    </div>
                                </div>
                                <div class="panel">
                                    <div class="panel-body">
                                        <label>问卷logo（暂未启用）</label>
                                        <input type="file">
                                        <label class="mg-t">问卷类型：<span id="quiz_type">type</span></label>



                                    </div>
                                </div>

                                <div class="panel">
                                    <div class="panel-body">
                                        <label>问卷显示标题</label>
                                        <input type="text" class="form-control" id="quiz_pagetitle"/>
                                        <label>问卷的简介信息</label>
                                        <textarea rows="10" cols="20" class="form-control" id="quiz_pageintroduce"></textarea>
                                        <label>问卷的提示信息</label>
                                        <textarea rows="10" cols="20" class="form-control" id="quiz_pagetips"></textarea>
                                    </div>
                                    <div class="panel-footer"><a class="btn btn-success" id="commit_change">保存修改</a></div>
                                </div>

                            </div>

                        </div>
                    </div>
                </div>
            </div>


        </div>
    </div>

    <!--footer start-->
    <include file="Common/footer" />
    <!--footer end-->
</div></body></html>

<script src="__PUBLIC__/asset/vendor/fuelux/checkbox.js" type="text/javascript"></script>
<script>
$(document).ready(function(){

    loadInfo();


    function loadInfo()
    {
        $.ajax({
            type:"POST",
            url:"/TestAdmin/QuizInfo/getQuizInfo",
            dataType:"json",
            data:{
                quiz_name:$("#quiz_list_select").val()
            },
            success:function(data){
                pushInfo(data);
            },error: function (jqXHR) {
                alert("获取问卷信息failed"+jqXHR.status);
            }
        });
    }


    $("#quiz_list_select").change(function(){
        loadInfo()
    });

    function pushInfo(data)
    {
        if (data.quiz_type == 'SCORE'){
            $("#quiz_type").html("计分型");
        }
        else if(data.quiz_type == 'COUNT'){
            $("#quiz_type").html("统计型");
        }

        $("#quiz_pagetitle").val(data.quiz_pagetitle);

        $("#quiz_pageintroduce").val(data.quiz_pageintroduce);
        $("#quiz_pagetips").val(data.quiz_pagetips);

        if (data.isvisible == "1"){
            $("#isvisible").checkbox('check');
        }
        else{

            $("#isvisible").checkbox('uncheck');
        }
    }

    $("#commit_change").click(function(){

        var visible = 0;

        if ( $("#isvisible").checkbox('isChecked')){
            visible = 1;
        }


        $.ajax({
            type:"POST",
            url:"/TestAdmin/QuizInfo/changeQuizInfo",
            dataType:"json",
            data:{
                quiz_name:$("#quiz_list_select").val(),
                isvisible:visible,
                quiz_pagetitle:$("#quiz_pagetitle").val(),
                quiz_pageintroduce:$("#quiz_pageintroduce").val(),
                quiz_pagetips:$("#quiz_pagetips").val()
            },
            success:function(data){
                alert(data.msg);
            },failed: function (jqXHR) {
                alert("修改问卷信息failed"+jqXHR.status);
            }
        });
    });


});
</script>